
var convertPopover = function(obj,isHorizontal){
    //转换成ipad下的坐标
    var result = obj;
    var index;

    if ((index = obj.indexOf("px")) >= 0){
        result = obj.substring(0,index);
    }

    else if ((index = obj.indexOf("%"))>= 0){
        result = obj.substring(0,index); 
        var length = (isHorizontal) ? 768 : 1024;
        result = length * result/100.0;
    }

    return result;
};

define([],function(){

    var PopPostion = {

        createPopPostion:function(popover){
            if (!popover || typeof(popover) == "undefined") {
                return;
            }

            var top = convertPopover(popover["top"],false);
            var left = convertPopover(popover["left"],true);
            var w = convertPopover(popover["width"],true);
            var h = convertPopover(popover["height"],false);

            popoverValue = { 
                  x : left,
                  y :  top,
                  width : w,
                  height : h,
            };

            return popoverValue;
        }
    };

    return PopPostion;
});
